package com.aaa.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Collection;
import java.util.List;

/**
 * 员工数据表字段
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Staff implements UserDetails {
    private Integer id;
    private String sname;
    private String phone;
    private String idcard;
    private String sex;
    private String pswd;
    private String state;
    private List<Role> roles;
    private boolean isAccountNonExpired=true;//账号是否是不过时的
    private boolean isAccountNonLocked=true;//账号是否是不锁定的
    private boolean isCredentialsNonExpired=true;//是否身份验证是不过期的


    private boolean isEnabled=true;//是否账号是被禁用的
    //用户的授权信息
    private Collection<? extends GrantedAuthority> authorities;

    @Override
    public String getPassword() {
        return this.pswd;
    }

    @Override
    public String getUsername() {
        return this.sname;
    }

    public boolean isEnabled() {
        return this.state.equals("正常");
    }
}
